home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / stk.init < prev    next >
Text File  |  1999-04-19  |  8KB  |  249 lines

  1. ;;;"STk.init" SLIB Initialization for STk    -*-scheme-*-
  2. ;;; Authors: Erick Gallesio (eg@unice.fr) and Aubrey Jaffer.
  3. ;;;
  4. ;;; This code is in the public domain.
  5.  
  6. (require "unix")
  7.  
  8. ;;; (software-type) should be set to the generic operating system type.
  9. ;;; UNIX, VMS, MACOS, AMIGA and MSDOS are supported.
  10.  
  11. (define (software-type) 'UNIX)
  12.  
  13. ;;; (scheme-implementation-type) should return the name of the scheme
  14. ;;; implementation loading this file.
  15.  
  16. (define (scheme-implementation-type) '|STk|)
  17.  
  18. ;;; (scheme-implementation-home-page) should return a (string) URL
  19. ;;; (Uniform Resource Locator) for this scheme implementation's home
  20. ;;; page; or false if there isn't one.
  21.  
  22. (define (scheme-implementation-home-page)
  23.   "http://kaolin.unice.fr/STk/STk.html")
  24.  
  25. ;;; (scheme-implementation-version) should return a string describing
  26. ;;; the version the scheme implementation loading this file.
  27.  
  28. (define (scheme-implementation-version) (version))
  29.  
  30. ;;; (implementation-vicinity) should be defined to be the pathname of
  31. ;;; the directory where any auxillary files to your Scheme
  32. ;;; implementation reside.
  33.  
  34. (define (implementation-vicinity) "/usr/local/lib/stk/3.99.3/")
  35.  
  36. ;;; (library-vicinity) should be defined to be the pathname of the
  37. ;;; directory where files of Scheme library functions reside.
  38.  
  39. (define library-vicinity
  40.   (let ((library-path (or (getenv "SCHEME_LIBRARY_PATH") "/usr/local/lib/slib/")))
  41.     (lambda () library-path)))
  42.  
  43. ;;; 
  44. ;;;
  45. (define home-vicinity
  46.   (let ((home-path (or (getenv "HOME") "/")))
  47.     (lambda () home-path)))
  48.  
  49. ;;; *FEATURES* should be set to a list of symbols describing features
  50. ;;; of this implementation.  Suggestions for features are:
  51.  
  52. (define *features*
  53.       '(
  54.     source                ;can load scheme source files
  55.                     ;(slib:load-source "filename")
  56.     compiled            ;can load compiled files
  57.                     ;(slib:load-compiled "filename")
  58.     rev4-report            ;conforms to
  59. ;    rev3-report            ;conforms to
  60. ;    ieee-p1178            ;conforms to
  61. ;    sicp                ;runs code from Structure and
  62.                     ;Interpretation of Computer
  63.                     ;Programs by Abelson and Sussman.
  64.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  65.                     ;LIST->STRING, STRING-COPY,
  66.                     ;STRING-FILL!, LIST->VECTOR,
  67.                     ;VECTOR->LIST, and VECTOR-FILL!
  68. ;    rev3-procedures            ;LAST-PAIR, T, and NIL
  69. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  70.                     ;SUBSTRING-MOVE-RIGHT!,
  71.                     ;SUBSTRING-FILL!,
  72.                     ;STRING-NULL?, APPEND!, 1+,
  73.                     ;-1+, <?, <=?, =?, >?, >=?
  74.     multiarg/and-            ;/ and - can take more than 2 args.
  75.     multiarg-apply            ;APPLY can take more than 2 args.
  76. ;    rationalize
  77.     delay                ;has DELAY and FORCE
  78.     with-file            ;has WITH-INPUT-FROM-FILE and
  79.                     ;WITH-OUTPUT-FROM-FILE
  80.     string-port            ;has CALL-WITH-INPUT-STRING and
  81.                     ;CALL-WITH-OUTPUT-STRING
  82. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  83. ;    char-ready?
  84. ;    macro                ;has R4RS high level macros
  85. ;    defmacro            ;has Common Lisp DEFMACRO
  86.     eval                ;SLIB:EVAL is single argument eval
  87. ;    record                ;has user defined data structures
  88. ;    values                ;proposed multiple values
  89.     dynamic-wind            ;proposed dynamic-wind
  90.     ieee-floating-point        ;conforms to
  91.     full-continuation        ;can return multiple times
  92. ;    object-hash            ;has OBJECT-HASH
  93.  
  94. ;    sort                ; commented because icomplete
  95. ;    queue                ;queues
  96. ;    pretty-print
  97. ;    object->string
  98. ;    format
  99. ;    compiler            ;has (COMPILER)
  100.     ed                ;(ED) is editor
  101.     system                ;posix (system <string>)
  102.     getenv                ;posix (getenv <string>)
  103. ;    program-arguments        ;returns list of strings (argv)
  104. ;    Xwindows            ;X support
  105. ;    curses                ;screen management package
  106. ;    termcap                ;terminal description package
  107. ;    terminfo            ;sysV terminal description
  108.     ))
  109.  
  110. ;;; (OUTPUT-PORT-WIDTH <port>)
  111. (define (output-port-width . arg) 79)
  112.  
  113. ;;; (OUTPUT-PORT-HEIGHT <port>)
  114. (define (output-port-height . arg) 24)
  115.  
  116. ;;; (TMPNAM) makes a temporary file name.
  117. (define tmpnam (let ((cntr 100))
  118.          (lambda () (set! cntr (+ 1 cntr))
  119.              (string-append "slib_" (number->string cntr)))))
  120.  
  121. ;;; (DELETE-FILE <string>)
  122. (define (delete-file f) (system (format #f "/bin/rm ~A" f)))
  123.  
  124. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  125. ;;; use this definition if your system doesn't have such a procedure.
  126. (define (force-output . arg) (apply flush arg))
  127.  
  128. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  129. ;;; be returned by CHAR->INTEGER.
  130. (define char-code-limit 256)
  131.  
  132. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  133. (define most-positive-fixnum #x0fffffff)
  134.  
  135. ;;; If your implementation provides eval SLIB:EVAL is single argument
  136. ;;; eval using the top-level (user) environment.
  137. (define slib:eval eval)
  138.  
  139. ;;; If your implementation provides R4RS macros:
  140. ;(define macro:eval slib:eval)
  141. ;(define macro:load load)
  142.  
  143. (define *macros* '())
  144.  
  145. (define-macro (defmacro name args . body)
  146.   `(begin
  147.      (define-macro (,name ,@args) ,@body)
  148.      (set! *macros* (cons ,name *macros*))))
  149.  
  150.  
  151. (define (defmacro? m) (and (memv m *macros*) #t))
  152.  
  153. (define macroexpand-1 MACRO-EXPAND-1)
  154. (define macroexpand   MACRO-EXPAND)
  155.  
  156.  
  157. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  158.  
  159. (define gentemp   GENSYM)
  160. (define base:eval slib:eval)
  161.  
  162. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  163. (define (defmacro:expand* x)
  164.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  165.  
  166. (define (defmacro:load <pathname>)
  167.   (slib:eval-load <pathname> defmacro:eval))
  168.  
  169. (define (slib:eval-load <pathname> evl)
  170.   (if (not (file-exists? <pathname>))
  171.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  172.   (call-with-input-file <pathname>
  173.     (lambda (port)
  174.       (let ((old-load-pathname *load-pathname*))
  175.     (set! *load-pathname* <pathname>)
  176.     (do ((o (read port) (read port)))
  177.         ((eof-object? o))
  178.       (evl o))
  179.     (set! *load-pathname* old-load-pathname)))))
  180.  
  181. ;;; define an error procedure for the library
  182. (define (slib:error . args)
  183.   (error (apply string-append (map (lambda (x) (format #f " ~a" x)) args))))
  184.  
  185.  
  186. ;;; define these as appropriate for your system.
  187. (define slib:tab     (integer->char 9))
  188. (define slib:form-feed  (integer->char 12))
  189.  
  190. ;;; Define these if your implementation's syntax can support it and if
  191. ;;; they are not already defined.
  192. (define -1+ 1-)
  193.  
  194. (define in-vicinity string-append)
  195.  
  196. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  197. ;;; return if exitting not supported.
  198. (define slib:exit exit)
  199.  
  200. ;;; Here for backward compatability
  201. (define scheme-file-suffix
  202.   (let ((suffix (case (software-type)
  203.           ((NOSVE) "_scm")
  204.           (else ".scm"))))
  205.     (lambda () suffix)))
  206.  
  207. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  208. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  209.  
  210. (define slib:load-source LOAD)
  211.  
  212. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  213. ;;; by compiling "foo.scm" if this implementation can compile files.
  214. ;;; See feature 'COMPILED.
  215.  
  216. (define slib:load-compiled load)
  217.  
  218. ;;;
  219. ;;; Retain original require/provide before loading "require.scm"
  220. ;;;
  221. (define stk:require require)
  222. (define stk:provide provide)
  223. (define stk:provided? provided?)
  224.  
  225. (define slib:load slib:load-source)
  226. (slib:load (in-vicinity (library-vicinity) "require"))
  227.  
  228.  
  229. ;;;
  230. ;;; Redefine require/provide so that symbols use SLIB one and strings use STk one
  231. ;;;
  232.  
  233. (define require
  234.   (let ((slib:require require))
  235.     (lambda (item)
  236.       ((if (symbol? item) slib:require stk:require) item ))))
  237.  
  238. (define provide
  239.   (let ((slib:provide provide))
  240.     (lambda (item)
  241.       ((if (symbol? item) slib:provide stk:provide) item))))
  242.  
  243. (define provided?
  244.   (let ((slib:provided? provided?))
  245.     (lambda (item)
  246.       ((if (symbol? item) slib:provided? stk:provided?) item))))
  247.  
  248. (define identity (lambda (x) x))
  249.